package com.zkadmin.renderer;

import java.util.Set;

import org.zkoss.zul.Listitem;
import org.zkoss.zul.ListitemRenderer;

import com.zkadmin.entity.SysResource;

public class RoleResourceListRenderer extends BaseRenderer implements ListitemRenderer<SysResource> {
	private Set<SysResource> roleResources;

	public RoleResourceListRenderer(Set<SysResource> roleResources) {
		this.roleResources = roleResources;
	}

	@Override
	public void render(Listitem listitem, final SysResource resource, int index) throws Exception {
		listitem.setAttribute("resourceId", resource.getId());
		if (roleResources.contains(resource)) {
			listitem.setSelected(true);
		}
		createListcell(listitem).setLabel(resource.getName());
		createListcell(listitem).setLabel(resource.getPermission());
	}
}
